import scrapy
# from util.headers import get_header

class QimaoSpider(scrapy.Spider):
    name = "qimao"
    # allowed_domains = ["yyjhbg.com"]
    start_urls = [f"https://www.qimao.com/qimaoapi/api/rank/book-list?is_girl=0&rank_type=1&date_type=1&date=202510&page={i}"for i in range(1,6)]

    def parse(self, response):
        print(f'正在爬取{response.url}页数据')
        for item in response.json()['data']['table_data']:
            author = item['author']
            title = item['title']
            intro = item['intro']
            img_url = item['image_link']
            data={
                'author':author,
                'title':title,
                'intro':intro,
                'img_url':img_url
            }
            yield data
